package com.capgemini.scaffold.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.capgemini.scaffold.common.ResponseBean;
import com.capgemini.scaffold.dto.AfterDTO;
import com.capgemini.scaffold.dto.FrontDTO;
import com.capgemini.scaffold.entity.After;
import com.capgemini.scaffold.entity.Front;
import com.capgemini.scaffold.mapper.AfterMapper;
import com.capgemini.scaffold.mapper.FrontMapper;
import com.capgemini.scaffold.service.AfterService;
import com.capgemini.scaffold.service.FrontService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 实习生前端成绩controller类
 */
@Api("实习生后端成绩")
@RestController
@RequestMapping("/after")
public class AfterController {

    @Autowired
    AfterService afterService;
    @Resource
    private AfterMapper afterMapper;

    @ApiOperation("实习生成绩模糊查询接口")
    @PostMapping("/queryAfter")
    public ResponseBean<List<Front>> queryUser(@RequestBody AfterDTO req) {
        return ResponseBean.success(afterService.queryFront(req));
    }

    @ApiOperation("分页查询用户信息")
    @PostMapping("/queryAfterPage")
    public ResponseBean<IPage<Front>> queryUserPage(@RequestBody AfterDTO req) {
        return ResponseBean.success(afterService.findFrontPage(req));
    }
    @ApiOperation("删除实习生成绩信息")
    @DeleteMapping("/{id}")
    public ResponseBean<Front> delFrontById(@PathVariable("id") Integer id){
        return ResponseBean.success(afterMapper.deleteById(id));
    }

    @ApiOperation("修改实习生成绩信息")
    @PutMapping
    public ResponseBean<Front> updataFront(@RequestBody After after){
        return ResponseBean.success(afterMapper.updateById(after));
    }


    @ApiOperation("插入实习生成绩信息")
    @PostMapping
    public ResponseBean<Front> insertFront(@RequestBody After after){
        return ResponseBean.success(afterMapper.insert(after));
    }
}
